View.vue
<template>
  <h1>表格组件</h1>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="date" label="Date" width="180" />
    <el-table-column prop="name" label="Name" width="180" />
    <el-table-column prop="address" label="Address" />
  </el-table>
  <hr>
  <el-table :data="arr" style="width:50%;margin:0 auto;">
    <el-table-column label="编号" type="selection" align="center" width="60px"></el-table-column>
    <el-table-column label="姓名" prop="name" align="center"></el-table-column>
    <el-table-column label="工资" prop="salary" align="center"></el-table-column>
    <el-table-column label="岗位" prop="job" align="center"></el-table-column>
    <el-table-column label="操作" align="center"><el-button type="danger" >删除</el-button></el-table-column>
  </el-table>
  <hr>
  <el-table :data="arr" style="width:50%;margin:0 auto;">
    <el-table-column label="编号" type="index" align="center" width="60px"></el-table-column>
    <el-table-column label="姓名" prop="name" align="center"></el-table-column>
    <el-table-column label="工资" prop="salary" align="center"></el-table-column>
    <el-table-column label="岗位" prop="job" align="center"></el-table-column>
    <el-table-column label="操作" align="center">
      <template #default="scope">
        <el-button type="danger" @click="del(scope.$index,scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script setup>
  import {ref} from "vue";

  const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
  const arr = ref ([
    {name:'张三',salary:'3000',job:'维修员'},
    {name:'李四',salary:'4000',job:'销售员'},
    {name:'王五',salary:'2000',job:'护林员'},
    {name:'赵六',salary:'5000',job:'程序猿'}
  ]);
  const del = (index,emp) => {
  if(confirm('确认删除'+emp.name+'吗？')){
    arr.value.splice(index,1);
  }

}
</script>

<style scoped>

</style>